<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <title>Document</title>
    <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/zTree.v3/3.5.33/css/zTreeStyle/zTreeStyle.min.css" />
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/custom-themes.css">
    <link rel="stylesheet" href="/static/css/custom.css">
</head>
<body>
<div class="container-fluid">
    <div class="row p-3">
        <div class="col">
            <form class="needs-validation" novalidate>
                <div class="form-row">
                    <div class="col-sm-6 mb-3">
                        <label for="" class="h4">权限说明</label>
                        <input type="text" class="form-control form-control-sm" id="name" name="name" placeholder="权限说明" required>
                        <div class="valid-tooltip">good</div>
                        <div class="invalid-tooltip">权限说明</div>
                    </div>
                </div>
                <div class="form-row">
                    <div class="col-sm-6 mb-3">
                        <label for="" class="h4">uri</label>
                        <input type="text" class="form-control form-control-sm" id="uri" name="uri" placeholder="uri" required>
                        <div class="invalid-tooltip">uri</div>
                    </div>
                </div>
                <div class="form-row">
                    <div class="col-sm-6 mb-3">
                        <label for="" class="h4">备注</label>
                        <input type="text" class="form-control form-control-sm" id="desc" name="desc" placeholder="备注">
                        <div class="invalid-tooltip">备注</div>
                    </div>
                </div>
                <button class="btn btn-sm btn-primary" type="submit">提交</button>
            </form>
        </div>
    </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js" type="text/javascript"></script>
<script src="https://cdn.bootcss.com/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://cdn.bootcss.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="/static/plugins/layui/layui.all.js"></script>
<script src="/static/js/buttonLoading.js"></script>
<script src="/static/js/custom.js"></script>
<script>
    $(function () {
        'use strict';
        $("form").submit(function () {
            event.preventDefault();
            event.stopPropagation();
            if (this.checkValidity()) {
                /* 允许提交 */
                let loading = layer.load(1, {shade: 0.3});
                request('/privilege/add', $("form").serializeObject(), function (e) {
                    layer.closeAll('loading');
                    if (e.code === 0) {
                        closePage(e.msg);
                        //刷新父级
                        parent.reloadTable();
                    } else {
                        layer.msg(e.msg);
                    }
                });
            }
            $(this).addClass('was-validated');
            return false;
        })
    });
</script>
</body>
</html>